package Fuente;
import Comun.clsSaicFrame;
import java.sql.SQLException;
import javax.swing.table.DefaultTableModel;

public class Banco  extends clsSaicFrame {
DefaultTableModel modelo;
    public Banco() {
        initComponents();
        
        modelo  = (DefaultTableModel) this.dataTable1.getModel();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dataSource1 = new FuenteDeDatos.DataSource();
        panelRoundTranslucido1 = new Comun.PanelRoundTranslucido();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        dataTable1 = new FuenteDeDatos.DataTable();
        jTextField1 = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        buttonSeven4 = new org.edisoncor.gui.button.ButtonSeven();
        buttonSeven5 = new org.edisoncor.gui.button.ButtonSeven();

        dataSource1.setCodigosql("select * from vw_v1;");
        dataSource1.setDb("db_saic");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setUndecorated(true);

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 30)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Banco de Sangre");

        dataTable1.setBackground(new java.awt.Color(153, 204, 255));
        dataTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        dataTable1.setColor(new java.awt.Color(255, 255, 255));
        dataTable1.setData(dataSource1);
        jScrollPane1.setViewportView(dataTable1);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "+", "-" }));

        jLabel2.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 18));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Seleccione un Tipo de Sangre");

        jLabel3.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 18));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Unidades Disponibles");

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "A", "B", "AB", "O" }));

        buttonSeven4.setText("Buscar");
        buttonSeven4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSeven4ActionPerformed(evt);
            }
        });

        buttonSeven5.setText("Imprimir");

        org.jdesktop.layout.GroupLayout panelRoundTranslucido1Layout = new org.jdesktop.layout.GroupLayout(panelRoundTranslucido1);
        panelRoundTranslucido1.setLayout(panelRoundTranslucido1Layout);
        panelRoundTranslucido1Layout.setHorizontalGroup(
            panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 943, Short.MAX_VALUE)
            .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(panelRoundTranslucido1Layout.createSequentialGroup()
                    .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, panelRoundTranslucido1Layout.createSequentialGroup()
                            .addContainerGap()
                            .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(panelRoundTranslucido1Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, panelRoundTranslucido1Layout.createSequentialGroup()
                                            .add(jLabel2)
                                            .add(178, 178, 178)
                                            .add(jComboBox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 152, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 152, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                    .add(18, 18, 18)
                                    .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(buttonSeven5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(buttonSeven4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .add(panelRoundTranslucido1Layout.createSequentialGroup()
                                    .add(28, 28, 28)
                                    .add(jLabel3)
                                    .add(40, 40, 40)
                                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 173, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                    .addContainerGap(40, Short.MAX_VALUE)))
        );
        panelRoundTranslucido1Layout.setVerticalGroup(
            panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 504, Short.MAX_VALUE)
            .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(panelRoundTranslucido1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jLabel1)
                    .add(44, 44, 44)
                    .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel2)
                        .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jComboBox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(buttonSeven4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                    .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(panelRoundTranslucido1Layout.createSequentialGroup()
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 266, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(44, 44, 44)
                            .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel3, 0, 0, Short.MAX_VALUE)))
                        .add(panelRoundTranslucido1Layout.createSequentialGroup()
                            .add(buttonSeven5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(303, 303, 303)))
                    .addContainerGap()))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(panelRoundTranslucido1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(panelRoundTranslucido1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(40, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

        private void buttonSeven4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSeven4ActionPerformed
         if (this.jComboBox1.getSelectedIndex() == 0 || this.jComboBox2.getSelectedIndex() == 0) {
             this.dataTable1.setModel(modelo);
             this.jTextField1.setText("");
         } else {
             this.dataTable1.setModel(modelo);
             try {
                 String x = String.valueOf(this.jComboBox2.getSelectedItem()) + String.valueOf(this.jComboBox1.getSelectedItem());
                 //System.out.println(x);
                 this.dataSource1.ejecutarPA("call  sp_llamar_vista_c1('" + x + "');");
                 this.dataSource1.consulta();
                 this.jTextField1.setText(this.dataSource1.consultaSN("select count(*) from vw_v1;").getString(1));
             } catch (SQLException ex) {
                 this.jTextField1.setText("");
             }         
         }     
    }//GEN-LAST:event_buttonSeven4ActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Banco();
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.button.ButtonSeven buttonSeven4;
    private org.edisoncor.gui.button.ButtonSeven buttonSeven5;
    private FuenteDeDatos.DataSource dataSource1;
    private FuenteDeDatos.DataTable dataTable1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    private Comun.PanelRoundTranslucido panelRoundTranslucido1;
    // End of variables declaration//GEN-END:variables

}
